package com.yang.concurrency.chapter7;

/**
 * @Author: 血魔
 * @Date: Created in 17:20 2021/12/12
 * @Version: $
 */
public class TicketWindowRunnable implements Runnable{

    private static final int MAX = 5;
    static int index = 0;
    @Override
    public void run() {
        while(true){
            synchronized (this){
                if(index > MAX)
                    break;
                try{
                    Thread.sleep(5);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + " 的号码是： " + (index++));
            }
        }
    }
}
